#ifndef _ALIASTYPE_H_
#define _ALIASTYPE_H_
#include "SimpleNode.h"
#include "ast/NameTok.h"
class IVisitor;
class aliasType;
typedef QSharedPointer<aliasType> aliasTypePtr;

class aliasType: public SimpleNode
{
public:
    explicit aliasType(const NameTokPtr& name, const NameTokPtr& asname, int nodeId=-1);
    virtual ~aliasType();
    
    
    NameTokPtr name();
    void setName(const NameTokPtr& name);
    
    NameTokPtr asname();
    void setAsname(const NameTokPtr& asname);
    
    
    virtual QString type() const;
    virtual QString toString() const;
    virtual void accept(IVisitor* visitor, const SimpleNodePtr& node);
    virtual void traverse(IVisitor* visitor);
private:
    NameTokPtr _name;
    NameTokPtr _asname;
};



typedef QListIterator<aliasTypePtr> AliasTypePtrListIterator;

class AliasTypeList: public QList<aliasTypePtr>
{
public:
    inline AliasTypeList() { }
    inline explicit AliasTypeList(aliasTypePtr i) { append(i); }
    inline AliasTypeList(const AliasTypeList &l) : QList<aliasTypePtr>(l) { }
    inline AliasTypeList(const QList<aliasTypePtr> &l) : QList<aliasTypePtr>(l) { }

    inline AliasTypeList operator+(const AliasTypeList &other) const
    { AliasTypeList n = *this; n += other; return n; }
    inline AliasTypeList &operator<<(aliasTypePtr it)
    { append(it); return *this; }
    inline AliasTypeList &operator<<(const AliasTypeList &l)
    { *this += l; return *this; }

    QString toString() const
    {
        QString str("AliasTypeList(");
        foreach(aliasTypePtr it, *this){
            if (it != NULL){
                str += it->toString()+",";
            }
        }
        str += ")";
        return str;
    }

    void traverse(IVisitor* visitor)
    {
        foreach(aliasTypePtr it, *this){
            if (it != NULL){
                it->accept(visitor, it);
            }
        }
    }
};



#endif